<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>管理员登录-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./static/css/font.css">
	<link rel="stylesheet" href="./static/css/weadmin.css">
    <script src="/assets/js/jquery.min.js" charset="utf-8"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>

</head>
<body class="login-bg">
    
    <div class="login">
        <div class="message">管理员登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input id="acc" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input id="pwd" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input class="loginin" value="登录" lay-submit lay-filter="login" style="width:100%;" type="button" id="adminLogin">
            <hr class="hr20" >



            <div>

            </div>
        </form>
    </div>
    <script src="/assets/js/jquery.cookie.js"></script>
    <script type="text/javascript">


       /* $.ajax({
            url: "./json/menu.json", //json文件位置
            type: "GET",
            dataType: "json",
            success: function(data) {
                alert(JSON.stringify(data));
            }
        })
*/

        layui.extend({
            admin: '{/}./static/js/admin'
        });
        layui.use(['form','admin'], function(){
          var form = layui.form
            ,admin = layui.admin;

            /*    form.on('submit(login)', function(data){
                 /*   sessionStorage.setItem("login",0);
                    if (data.field.acc == "22" && data.field.pwd == "123") location.href='./index.html';
                  console.info(  data.field.acc +"  "+data.field.pwd );
              /* layer.msg(JSON.stringify(data.field),function(){
                      location.href='./index.html'
                  });
               else layer.msg("账号或者密码错误");
                return false;
          });*/


        });

        $(function () {
            var webPath = "/auth";


            $("#adminLogin").click(function () {
                var acc = $("#acc").val();
                var pwd = $("#pwd").val();
                if (acc.trim() == '' || acc == null ){
                    layer.msg("请输入账号");
                    return;
                }
                if (pwd.trim() == '' || pwd == null ){
                    layer.msg("请输入密码    ");
                    return;
                }

                var obj = {acc:acc,pwd:pwd};

                $.ajax({
                    url: webPath+"/adminAcc/adminLogin",
                    type: "POST",
                    data:JSON.stringify(obj),
                    contentType: 'application/json;charset=utf-8',
                    success: function(data) {
                        if (data.errorCode == "0") {
                            console.info(data.body);
                            console.info("flag :"+ data.body.flag);
                            if (data.body.flag == false) {
                                layer.msg("账号或密码错误");
                                return;
                            }
                            if (data.body.userInfo != null && data.body.userInfo.status == '0' ) {
                                layer.msg("账号被冻结");
                                return;
                            }
                            //登陆成功
                            sessionStorage.setItem("userInfo",JSON.stringify(data.body.userInfo) );
                            sessionStorage.setItem("menuInfo",JSON.stringify(data.body.menuInfo) );

                            sessionStorage.setItem("roleInfo",JSON.stringify(data.body.roleInfo) );

                            layer.msg("登陆成功");

                            console.info(data.body);
                            sessionStorage.setItem("token",data.body.token);
                            $.cookie("token", data.body.token );


                            setTimeout(function () {
                                location.href='./index.html';
                            },1000)

                        }else layer.msg("登陆失败 "+JSON.stringify(data))

                    },
                    error: function(xhr, type, errorThrown) {
                        layer.msg("失败  "+JSON.stringify(xhr.responseJSON)  );
                        console.info(JSON.stringify(xhr.responseJSON) +"   "+JSON.stringify(errorThrown));
                    }
                })//ajax
            });



        })

    </script>  
    <!-- 底部结束 -->
</body>
</html>